﻿using System.Net.Http;

using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
using NP.Enterprise.Utils.Http;
using System;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using NP.Enterprise.Utils.ApiResult;

namespace NP.BPMReportPlatform
{
    [DependsOn(
        typeof(BPMReportPlatformDomainModule),
        typeof(BPMReportPlatformApplicationContractsModule),
        typeof(AbpDddApplicationModule),
        typeof(AbpAutoMapperModule)
        )]
    public class BPMReportPlatformApplicationModule : AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAutoMapperObjectMapper<BPMReportPlatformApplicationModule>();
            Configure<AbpAutoMapperOptions>(options =>
            {
                options.AddMaps<BPMReportPlatformApplicationModule>(validate: false);
            });

            context.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            context.Services.AddHttpClient<BpmReportPlatformHttpClient>()
                .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
                {
                    ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
                });

        }
    }
}
